package day06;

import java.util.Arrays;
import java.util.Scanner;

public class HomeWork2 {
    public static void main(String[] args) {
        int n=6;
        double[] scores = inputData(n);
        double avg = calAvg(scores,n);
        System.out.println(avg);
        System.out.println("最终的平均分"+avg);
    }
    public static double[] inputData(int n){
        double[] scores = new double[n];
        Scanner scan = new Scanner(System.in);
        System.out.println("输入分数：");
        for (int i=0;i<n;i++){
            scores[i] = scan.nextDouble();
        }
        return scores;
    }
    public static double calAvg(double[] scores,int n){
        double avg = 0.0;
        double sum =0.0;
        Arrays.sort(scores);
        double[] fcoses = new double[n-2];
      System.arraycopy(scores,1,fcoses,0,n-2);
      for (int i=0;i<n-2;i++){
          sum+=fcoses[i];
      }
      avg = sum/(n-2);
      return avg;
    }
}
